package com.renwei.yunlong.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Project :  yunaandroid.
 * Package name: com.renwei.yunlong.adapter
 * Created by :  Benjamin.
 * Created time: 2017/12/2 19:38
 * Changed by :  Benjamin.
 * Changed time: 2017/12/2 19:38
 * Class description:
 */

public class PagerViewAdapter extends PagerAdapter {
    private List<View> viewList;
    private Context context;

    public PagerViewAdapter(List<View> viewList, Context context) {
        super();
        this.viewList = viewList;
        this.context = context;
    }
    @Override
    public int getCount() {

        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {

        return arg0==arg1;
    }
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view=viewList.get(position);
        container.addView(view);
        return view;
    }
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

}
